package algorithm;

import java.util.Scanner;

/**
 * @author wxc
 * @date 2021年04月27日 9:51
 */
public class AlgorithmDemo01 {
    public static void main(String[] args) {
        //递归算法  来源于数学家斐波那契
        int num[] = new int[40];
        num[0] = 0;
        num[1] = 1;

        for (int i = 2; i < 40; i++) {
            num[i] = num[i - 1] + num[i - 2];
//            System.out.println(num[i]);
        }

//        System.out.println(sum(3));

//        System.out.println(jiecheng(5));
//
        int sum[] =new int[]{8,12,19,52,96,300};
        //从数组中查找52
        //时间复杂度 n
        //


        System.out.println(print("abcdeasgagg"));
    }
    private static int yPrint(int[] sum,int a) {
        int lastIndex=sum.length;
        int index = sum.length/2;


        return 0;
    }


    private static void xPrint(int[] sum) {
        for (int i : sum) {
            if (i==52){
                System.out.println(i);
            }
        }
    }


    /**
     * @param b
     * @return int
     * @author wxc
     * @date 2021/4/27 11:25
     * ----采用递归的思想，递归的三大要素
     */
    public static int sum(int b) {
        if (b < 2) {
            return b == 0 ? 0 : 1;
        }
        return sum(b - 1) + sum(b - 2);
    }

    /**
     * @param n
     * @return int
     * @author wxc
     * @date 2021/4/27 17:21
     */
    public static int jiecheng(int n) {
        if (n == 0) {
            return 1;
        }
        return n * jiecheng(n - 1);
    }

    public static String print(String abc) {
        int length = abc.length();
        //出口条件
        if (length == 1) {
            return abc;
        }
        //复用逻辑公式
        return abc.charAt(length - 1) + "" + print(abc.substring(0, length - 1));
    }


}
